package cn.liyunqi.prplug.controller;

import cn.liyunqi.prplug.bo.ImgViewPoint;
import cn.liyunqi.prplug.bo.PointInfo;
import cn.liyunqi.prplug.util.ImageUtil;
import cn.liyunqi.prplug.util.PrPlugUtil;
import cn.liyunqi.prplug.view.AlertUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.melloware.jintellitype.HotkeyListener;
import com.melloware.jintellitype.JIntellitype;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.WindowEvent;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.io.*;
import java.math.BigDecimal;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

/**
 * @Auther: li.yunqi
 * @Date: 2019/10/14 09:50
 * @Description: TODO
 */
public class PrPlugController extends BaseFXController implements WindowCloseHandler{

    public static final String APPDATA_FOLDER = "pr-plug-data";

    private static final String APPDATA_APPIMG = "pr-plug-img.jpg";

    private static final String APPDATA_POINT = "pr-plug-point.json";

    private static final String APPDATA_EFFECT = "pr-plug-effect.json";

    public static final String APPDATA_SN = "SN.licence";

    private static final String VIDEO_TRACK = "video-track.png";

    Robot robot = new Robot();//创建Robot对象

    @FXML
    private TextField multiple;
    @FXML
    private TextField ignore;

    @FXML
    private ImageView imgView;

    @FXML
    private Pane imgPane;

    @FXML
    private ScrollPane imgScrollPane;

    @FXML
    private Label rememberPointTxt;

    private int rememberPoint =  0;

    //PR任务栏
    private ImageView prtaskbar;
    private Label prtaskbarLabel;
    @FXML
    private TextField prtaskbarX;
    @FXML
    private TextField prtaskbarY;

    //效果控件
    private ImageView control;
    private Label controlLabel;
    @FXML
    private TextField controlX;
    @FXML
    private TextField controlY;

    //位置移动点
    private ImageView position;
    private Label positionLabel;
    @FXML
    private TextField positionX;
    @FXML
    private TextField positionY;

    //缩放点
    private ImageView zoom;
    private Label zoomLabel;
    @FXML
    private TextField zoomX;
    @FXML
    private TextField zoomY;

    //缩放数值点
    private Label zoomDistLabel;
    private ImageView zoomDist;
    @FXML
    private TextField zoomDistX;
    @FXML
    private TextField zoomDistY;

    //缩放起始点
    private Label zoomStartLabel;
    private ImageView zoomStart;
    @FXML
    private TextField zoomStartX;
    @FXML
    private TextField zoomStartY;

    //缩放结束点
    private Label zoomEndLabel;
    private ImageView zoomEnd;
    @FXML
    private TextField zoomEndX;
    @FXML
    private TextField zoomEndY;

    //元数据
    private Label metadataLabel;
    private ImageView metadata;
    @FXML
    private TextField metadataX;
    @FXML
    private TextField metadataY;

    //素材名称点
    private Label materialNameLabel;
    private ImageView materialName;
    @FXML
    private TextField materialNameX;
    @FXML
    private TextField materialNameY;

    //音频点
    private ImageView audio;
    private Label audioLabel;
    @FXML
    private TextField audioX;
    @FXML
    private TextField audioY;

    //素材点击区
    private Label materialClickLabel;
    private ImageView materialClick;
    @FXML
    private TextField materialClickX;
    @FXML
    private TextField materialClickY;

    //效果区
    private Label effectLabel;
    private ImageView effect;
    @FXML
    private TextField effectX;
    @FXML
    private TextField effectY;

    //效果输入框
    private Label effectInputLabel;
    private ImageView effectInput;
    @FXML
    private TextField effectInputX;
    @FXML
    private TextField effectInputY;

    //效果选中区
    private Label effectClickLabel;
    private ImageView effectClick;
    @FXML
    private TextField effectClickX;
    @FXML
    private TextField effectClickY;

    //视频轨道起始点
    private Label videoStartLabel;
    private ImageView videoStart;
    @FXML
    private TextField videoStartX;
    @FXML
    private TextField videoStartY;

    //视频轨道结束点
    private Label videoEndLabel;
    private ImageView videoEnd;
    @FXML
    private TextField videoEndX;
    @FXML
    private TextField videoEndY;

    //点击频率
    @FXML
    private Slider frequency;
    @FXML
    private Label frequencyLabel;

    @FXML
    private VBox effectCheckBox;
    @FXML
    private VBox vboxoperation;
    @FXML
    private HBox mainHbox;

    private HotkeyListener hotkeyListener;

    private boolean stopFlag = false;

    public PrPlugController() throws AWTException {
    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {

        HBox.setHgrow(imgScrollPane,Priority.ALWAYS);
        //mainPane.setH

        //拖动条监听
        frequency.valueProperty().addListener(new ChangeListener<Number>() {
            public void changed(ObservableValue<? extends Number> ov,
                                Number old_val, Number new_val) {
                //cappuccino.setOpacity(new_val.doubleValue());
                frequencyLabel.setText(new_val.intValue() + "");
            }
        });

        //添加监听
        JIntellitype.getInstance().registerHotKey(1,
                 JIntellitype.MOD_CONTROL, 112);


        hotkeyListener = new HotkeyListener() {
            public void onHotKey(int markCode) {
                switch (markCode) {
                    case 1:
                        stopFlag = true;
                        //紧急停止功能呢
                        //JOptionPane.showMessageDialog(null, "注册快捷键(Shift+Ctrl+D):跳出弹框！", "提示消息",
                        //        JOptionPane.WARNING_MESSAGE);
                        break;
                }
            }
        };

        JIntellitype.getInstance().addHotKeyListener(hotkeyListener);

        String destPath = "." + File.separator + APPDATA_FOLDER + File.separator + APPDATA_APPIMG;
        File dest = new File(destPath);

        if(dest.exists()){
            showImg(destPath);
        }

        //获取默认配置 并填入值
        initPointInfo();

        InvalidationListener textFieldListener = new InvalidationListener() {
            @Override
            public void invalidated(Observable observable) {

                String observableStr =  observable.toString();

                //拆分获取
                String[] temp1Arr = observableStr.split("\\[");

                if(temp1Arr.length > 2){
                    String temp2 = temp1Arr[2].replace("]","");

                    String[] temp2Arr = temp2.split(",");

                    if(temp2Arr.length > 3){
                        try {
                            String id = temp2Arr[0].split("=")[1].trim();
                            String focused = temp2Arr[2].split(":")[1].trim();
                            String value = temp2Arr[3].split(":")[1].trim();

                            if("focused".equals(focused.toLowerCase()) && "true".equals(value.toLowerCase())){
                                if(prtaskbarX.getId().equals(id) || prtaskbarY.getId().equals(id)){
                                    rememberPoint = 0;
                                    rememberPointTxt.setText("PR任务栏");
                                }else if(controlX.getId().equals(id) || controlY.getId().equals(id)){
                                    rememberPoint = 1;
                                    rememberPointTxt.setText("效果控件");
                                }else if(positionX.getId().equals(id) || positionY.getId().equals(id)){
                                    rememberPoint = 2;
                                    rememberPointTxt.setText("位置移动点");
                                }else if(zoomX.getId().equals(id) || zoomY.getId().equals(id)){
                                    rememberPoint = 3;
                                    rememberPointTxt.setText("缩放点");
                                }else if(zoomDistX.getId().equals(id) || zoomDistY.getId().equals(id)){
                                    rememberPoint = 4;
                                    rememberPointTxt.setText("缩放数值点");
                                }else if(zoomStartX.getId().equals(id) || zoomStartY.getId().equals(id)){
                                    rememberPoint = 5;
                                    rememberPointTxt.setText("缩放起始点");
                                }else if(zoomEndX.getId().equals(id) || zoomEndY.getId().equals(id)){
                                    rememberPoint = 6;
                                    rememberPointTxt.setText("缩放结束点");
                                }else if(metadataX.getId().equals(id) || metadataY.getId().equals(id)){
                                    rememberPoint = 7;
                                    rememberPointTxt.setText("元数据");
                                }else if(materialNameX.getId().equals(id) || materialNameY.getId().equals(id)){
                                    rememberPoint = 8;
                                    rememberPointTxt.setText("素材名称点");
                                }else if(audioX.getId().equals(id) || audioY.getId().equals(id)){
                                    rememberPoint = 9;
                                    rememberPointTxt.setText("音频点");
                                }else if(materialClickX.getId().equals(id) || materialClickY.getId().equals(id)){
                                    rememberPoint = 10;
                                    rememberPointTxt.setText("素材点击区");
                                }else if(effectX.getId().equals(id) || effectY.getId().equals(id)){
                                    rememberPoint = 11;
                                    rememberPointTxt.setText("效果区");
                                }else if(effectInputX.getId().equals(id) || effectInputY.getId().equals(id)){
                                    rememberPoint = 12;
                                    rememberPointTxt.setText("效果输入框");
                                }else if(effectClickX.getId().equals(id) || effectClickY.getId().equals(id)){
                                    rememberPoint = 13;
                                    rememberPointTxt.setText("效果选中区");
                                }else if(videoStartX.getId().equals(id) || videoStartY.getId().equals(id)){
                                    rememberPoint = 14;
                                    rememberPointTxt.setText("视频轨道起始点");
                                }else if(videoEndX.getId().equals(id) || videoEndY.getId().equals(id)){
                                    rememberPoint = 15;
                                    rememberPointTxt.setText("视频轨道结束点");
                                }
                            }
                        }catch (Exception ex){

                        }

                    }
                }
            }
        };
        //0
        prtaskbarX.focusedProperty().addListener(textFieldListener);
        prtaskbarY.focusedProperty().addListener(textFieldListener);
        //1
        controlX.focusedProperty().addListener(textFieldListener);
        controlY.focusedProperty().addListener(textFieldListener);
        //2
        positionX.focusedProperty().addListener(textFieldListener);
        positionY.focusedProperty().addListener(textFieldListener);
        //3
        zoomX.focusedProperty().addListener(textFieldListener);
        zoomY.focusedProperty().addListener(textFieldListener);
        //4
        zoomDistX.focusedProperty().addListener(textFieldListener);
        zoomDistY.focusedProperty().addListener(textFieldListener);
        //5
        zoomStartX.focusedProperty().addListener(textFieldListener);
        zoomStartY.focusedProperty().addListener(textFieldListener);
        //6
        zoomEndX.focusedProperty().addListener(textFieldListener);
        zoomEndY.focusedProperty().addListener(textFieldListener);
        //7
        metadataX.focusedProperty().addListener(textFieldListener);
        metadataY.focusedProperty().addListener(textFieldListener);
        //8
        materialNameX.focusedProperty().addListener(textFieldListener);
        materialNameY.focusedProperty().addListener(textFieldListener);
        //9
        audioX.focusedProperty().addListener(textFieldListener);
        audioY.focusedProperty().addListener(textFieldListener);
        //10
        materialClickX.focusedProperty().addListener(textFieldListener);
        materialClickY.focusedProperty().addListener(textFieldListener);
        //11
        effectX.focusedProperty().addListener(textFieldListener);
        effectY.focusedProperty().addListener(textFieldListener);
        //12
        effectInputX.focusedProperty().addListener(textFieldListener);
        effectInputY.focusedProperty().addListener(textFieldListener);
        //13
        effectClickX.focusedProperty().addListener(textFieldListener);
        effectClickY.focusedProperty().addListener(textFieldListener);
        //14
        videoStartX.focusedProperty().addListener(textFieldListener);
        videoStartY.focusedProperty().addListener(textFieldListener);
        //15
        videoEndX.focusedProperty().addListener(textFieldListener);
        videoEndY.focusedProperty().addListener(textFieldListener);

        imgView.setOnMouseClicked(new EventHandler<MouseEvent>(){
            @Override
            public void handle(MouseEvent mouseEvent){
                String nextTxt = "";

                if(rememberPoint == 0){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent, prtaskbar, prtaskbarLabel, prtaskbarX, prtaskbarY, "PR任务栏");
                    prtaskbar = imgViewPoint.getImageView();
                    prtaskbarLabel = imgViewPoint.getLabel();
                    nextTxt = "效果控件";
                }else if(rememberPoint == 1){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,control,controlLabel,controlX,controlY,"效果控件");
                    control = imgViewPoint.getImageView();
                    controlLabel = imgViewPoint.getLabel();
                    nextTxt = "位置移动点";
                }else if(rememberPoint == 2){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,position,positionLabel,positionX,positionY,"位置移动点");
                    position = imgViewPoint.getImageView();
                    positionLabel = imgViewPoint.getLabel();
                    nextTxt = "缩放点";
                }else if(rememberPoint == 3){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,zoom,zoomLabel,zoomX,zoomY,"缩放点");
                    zoom = imgViewPoint.getImageView();
                    zoomLabel = imgViewPoint.getLabel();
                    nextTxt = "缩放数值点";
                }else if(rememberPoint == 4){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,zoomDist,zoomDistLabel,zoomDistX,zoomDistY,"缩放数值点");
                    zoomDist = imgViewPoint.getImageView();
                    zoomDistLabel = imgViewPoint.getLabel();
                    nextTxt = "缩放起始点";
                }else if(rememberPoint == 5){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,zoomStart,zoomStartLabel,zoomStartX,zoomStartY,"缩放起始点");
                    zoomStart = imgViewPoint.getImageView();
                    zoomStartLabel = imgViewPoint.getLabel();
                    nextTxt = "缩放结束点";
                }else if(rememberPoint == 6){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,zoomEnd,zoomEndLabel,zoomEndX,zoomEndY,"缩放结束点");
                    zoomEnd = imgViewPoint.getImageView();
                    zoomEndLabel = imgViewPoint.getLabel();
                    nextTxt = "元数据";
                }else if(rememberPoint == 7){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,metadata,metadataLabel,metadataX,metadataY,"元数据");
                    metadata = imgViewPoint.getImageView();
                    metadataLabel = imgViewPoint.getLabel();
                    nextTxt = "素材名称点";
                }else if(rememberPoint == 8){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,materialName,materialNameLabel,materialNameX,materialNameY,"素材名称点");
                    materialName = imgViewPoint.getImageView();
                    materialNameLabel = imgViewPoint.getLabel();
                    nextTxt = "音频点";
                }else if(rememberPoint == 9){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,audio,audioLabel,audioX,audioY,"音频点");
                    audio = imgViewPoint.getImageView();
                    audioLabel = imgViewPoint.getLabel();
                    nextTxt = "素材点击区";

                }else if(rememberPoint == 10){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,materialClick,materialClickLabel,materialClickX,materialClickY,"素材点击区");
                    materialClick = imgViewPoint.getImageView();
                    materialClickLabel = imgViewPoint.getLabel();
                    nextTxt = "效果区";
                }else if(rememberPoint == 11){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,effect,effectLabel,effectX,effectY,"效果区");
                    effect = imgViewPoint.getImageView();
                    effectLabel = imgViewPoint.getLabel();
                    nextTxt = "效果输入框";
                }else if(rememberPoint == 12){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,effectInput,effectInputLabel,effectInputX,effectInputY,"效果输入框");
                    effectInput = imgViewPoint.getImageView();
                    effectInputLabel = imgViewPoint.getLabel();
                    nextTxt = "效果选中区";
                }else if(rememberPoint == 13){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,effectClick,effectClickLabel,effectClickX,effectClickY,"效果选中区");
                    effectClick = imgViewPoint.getImageView();
                    effectClickLabel = imgViewPoint.getLabel();
                    nextTxt = "视频轨道起始点";
                }else if(rememberPoint == 14){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,videoStart,videoStartLabel,videoStartX,videoStartY,"视频轨道起始点");
                    videoStart = imgViewPoint.getImageView();
                    videoStartLabel = imgViewPoint.getLabel();
                    nextTxt = "视频轨道结束点";
                }else if(rememberPoint == 15){

                    ImgViewPoint imgViewPoint = setPoint(mouseEvent,videoEnd,videoEndLabel,videoEndX,videoEndY,"视频轨道结束点");
                    videoEnd = imgViewPoint.getImageView();
                    videoEndLabel = imgViewPoint.getLabel();
                    nextTxt = "PR任务栏";
                }

                rememberPointTxt.setText(nextTxt);
                rememberPoint = (rememberPoint + 1) % 16;
            }
        });

    }

    private ImgViewPoint setPointArea(MouseEvent mouseEvent, ImageView imgPoint, Label imgLable, TextField xField, TextField yField,
                                      TextField xField1, TextField yField1,
                                      TextField xField2, TextField yField2,
                                      TextField xField3, TextField yField3,
                                      TextField xField4, TextField yField4,
                                      String nowTxt){
        return setPointArea( mouseEvent.getX(),mouseEvent.getY(),  imgPoint,  imgLable,  xField,  yField,
                 xField1,  yField1,
                 xField2,  yField2,
                 xField3,  yField3,
                 xField4,  yField4,
                 nowTxt);
    }

    private ImgViewPoint setPointArea(Double x ,Double y, ImageView imgPoint, Label imgLable, TextField xField, TextField yField,
                                      TextField xField1, TextField yField1,
                                      TextField xField2, TextField yField2,
                                      TextField xField3, TextField yField3,
                                      TextField xField4, TextField yField4,
                                      String nowTxt){


        xField.setText(PrPlugUtil.safeValue(x));
        yField.setText(PrPlugUtil.safeValue(y));

        //4点判断
        try {
            double x1 = Double.valueOf(xField1.getText());

            double y1 = Double.valueOf(yField2.getText());

            double x2 = Double.valueOf(xField3.getText());

            double y2 = Double.valueOf(yField4.getText());

            if(x2 > x1 && y2 > y1){
                if(imgPoint == null){
                    imgPoint = new ImageView();
                    //Image img = new Image(f.toURI().toString());
                    Image img = new Image("icons/red.png");
                    // ImageView temp = new ImageView();
                    imgPoint.setImage(img);

                    imgPane.getChildren().add(imgPoint);

                    imgLable = new Label();
                    imgLable.setText(nowTxt);
                    //prtaskbarLabel.setTextFill(Color.YELLOW);
                    imgLable.setOpacity(0.7);
                    imgLable.setBackground(new Background(new BackgroundFill(Color.YELLOW,null,null)));
                    imgPane.getChildren().add(imgLable);
                }

                imgPoint.setX(x1);
                imgPoint.setY(y1);
                imgPoint.setFitWidth(x2 - x1);
                imgPoint.setFitHeight(y2 - y1);

                setLabelLayout(imgView,imgLable,x1,y1);

            }else{
                if(imgPoint != null){
                    imgPane.getChildren().remove(imgPoint);
                    imgPoint = null;
                }
                if(imgLable != null){
                    imgPane.getChildren().remove(imgLable);
                    imgLable = null;
                }
            }

        }catch (Exception ex){
            if(imgPoint != null){
                imgPane.getChildren().remove(imgPoint);
                imgPoint = null;
            }
            if(imgLable != null){
                imgPane.getChildren().remove(imgLable);
                imgLable = null;
            }
        }

        return  new ImgViewPoint(imgLable,imgPoint);
    }
    private ImgViewPoint setPoint(MouseEvent mouseEvent, ImageView imgPoint, Label imgLable, TextField xField, TextField yField, String nowTxt){

        return setPoint(mouseEvent.getX(),mouseEvent.getY(),imgPoint,imgLable,xField,yField,nowTxt);
    }

    private ImgViewPoint setPoint(Double x,Double y , ImageView imgPoint, Label imgLable, TextField xField, TextField yField, String nowTxt){

        xField.setText(PrPlugUtil.safeValue(x));
        yField.setText(PrPlugUtil.safeValue(y));

        if(x ==null || y == null){

            if(imgPoint != null){
                imgPane.getChildren().remove(imgPoint);
            }
            if(imgLable != null){
                imgPane.getChildren().remove(imgLable);
            }
            return new ImgViewPoint();
        }

        if(imgPoint == null){
            imgPoint = new ImageView();
            //Image img = new Image(f.toURI().toString());
            Image img = new Image("icons/redpoint.jpg");
            // ImageView temp = new ImageView();
            imgPoint.setImage(img);
            imgPoint.setFitWidth(5);
            imgPoint.setFitHeight(5);
            imgPane.getChildren().add(imgPoint);

            imgLable = new Label();
            imgLable.setText(nowTxt);
            //prtaskbarLabel.setTextFill(Color.YELLOW);
            imgLable.setOpacity(0.7);
            imgLable.setBackground(new Background(new BackgroundFill(Color.YELLOW,null,null)));
            imgPane.getChildren().add(imgLable);
        }

        ImgViewPoint imgViewPoint = new ImgViewPoint(imgLable,imgPoint);

        imgPoint.setX(x);
        imgPoint.setY(y);

        setLabelLayout(imgView,imgLable,x,y);

        return imgViewPoint;
    }

    private static void setLabelLayout(ImageView imgView,Label label,double x ,double y){
        double xValue = x + 7;
        double yValue = y;

        if(x + 7 + 50 >= imgView.getFitWidth()){
            xValue = x - 7 - 50;
        }
        if(y + 8 >= imgView.getFitHeight()){
            yValue = y - 8;
        }

        label.setLayoutX(xValue);
        label.setLayoutY(yValue);

    }

    private void showImg(String url){
        File f = new File(url);
        Image img = new Image(f.toURI().toString());

        imgView.setImage(img);

        imgPane.setPrefWidth(img.getWidth());
        imgPane.setPrefHeight(img.getHeight());

        imgView.setFitHeight(img.getHeight());
        imgView.setFitWidth(img.getWidth());
    }

    @FXML
    public void importImg(){
        FileChooser fileChooser = new FileChooser();//构建一个文件选择器实例
        File selectedFile = fileChooser.showOpenDialog(this.getPrimaryStage());

        fileChooser.setTitle("选择窗体截图");

        fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JPG Files", "*.jpg"));

        String path = selectedFile.getPath();

        File source = new File(path);

        if(!(source.isFile() && source.exists())){
            AlertUtil.showErrorAlert("请选择窗体文件");
        }

        String folderPath = "." + File.separator + APPDATA_FOLDER;

        File folder = new File(folderPath);

        if(!folder.exists()){
            folder.mkdir();
        }

        String destPath = "." + File.separator + APPDATA_FOLDER + File.separator + APPDATA_APPIMG;
        File dest = new File(destPath);

        InputStream input = null;
        OutputStream output = null;
        try {
            input = new FileInputStream(source);
            output = new FileOutputStream(dest);
            byte[] buf = new byte[1024];
            int bytesRead;
            while ((bytesRead = input.read(buf)) != -1) {
                output.write(buf, 0, bytesRead);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally{
            try {
                input.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                output.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        showImg(destPath);
    }

    @FXML
    public void startScript(){

        //判断当前电脑的有效性
        String sn = SNMessageController.getSN();
        sn = sn == null?"":sn;
        int result = PrPlugUtil.authApp(sn);

        if(result != 0){
            return;
        }

        //先把数据保存到bean 里面 再把数据写入文件中
        String pointDataPath = "." + File.separator + APPDATA_FOLDER + File.separator + APPDATA_POINT;

        File file = new File(pointDataPath);

        try {
            PointInfo pointInfo = new PointInfo();
            if (!PrPlugUtil.isDouble(prtaskbarX.getText()) || !PrPlugUtil.isDouble(prtaskbarY.getText())) {
                AlertUtil.showErrorAlert("PR任务栏不能为空");
                return;
            }
            pointInfo.setPrtaskbarX(Double.valueOf(prtaskbarX.getText()));
            pointInfo.setPrtaskbarY(Double.valueOf(prtaskbarY.getText()));

            if (!PrPlugUtil.isDouble(controlX.getText()) || !PrPlugUtil.isDouble(controlY.getText())) {
                AlertUtil.showErrorAlert("效果控件不能为空");
                return;
            }
            pointInfo.setControlX(Double.valueOf(controlX.getText()));
            pointInfo.setControlY(Double.valueOf(controlY.getText()));


            if (!PrPlugUtil.isDouble(positionX.getText()) || !PrPlugUtil.isDouble(positionY.getText())) {
                AlertUtil.showErrorAlert("位置移动点不能为空");
                return;
            }
            pointInfo.setPositionX(Double.valueOf(positionX.getText()));
            pointInfo.setPositionY(Double.valueOf(positionY.getText()));

            if (!PrPlugUtil.isDouble(zoomX.getText()) || !PrPlugUtil.isDouble(zoomY.getText())) {
                AlertUtil.showErrorAlert("缩放点不能为空");
                return;
            }
            pointInfo.setZoomX(Double.valueOf(zoomX.getText()));
            pointInfo.setZoomY(Double.valueOf(zoomY.getText()));

            if (!PrPlugUtil.isDouble(zoomDistX.getText()) || !PrPlugUtil.isDouble(zoomDistY.getText())) {
                AlertUtil.showErrorAlert("缩放数值点不能为空");
                return;
            }
            pointInfo.setZoomDistX(Double.valueOf(zoomDistX.getText()));
            pointInfo.setZoomDistY(Double.valueOf(zoomDistY.getText()));

            if (!PrPlugUtil.isDouble(zoomStartX.getText()) || !PrPlugUtil.isDouble(zoomStartY.getText())) {
                AlertUtil.showErrorAlert("缩放起始点不能为空");
                return;
            }
            pointInfo.setZoomStartX(Double.valueOf(zoomStartX.getText()));
            pointInfo.setZoomStartY(Double.valueOf(zoomStartY.getText()));

            if (!PrPlugUtil.isDouble(zoomEndX.getText()) || !PrPlugUtil.isDouble(zoomEndY.getText())) {
                AlertUtil.showErrorAlert("缩放结束点不能为空");
                return;
            }
            pointInfo.setZoomEndX(Double.valueOf(zoomEndX.getText()));
            pointInfo.setZoomEndY(Double.valueOf(zoomEndY.getText()));

            if (!PrPlugUtil.isDouble(metadataX.getText()) || !PrPlugUtil.isDouble(metadataY.getText())) {
                AlertUtil.showErrorAlert("元数据不能为空");
                return;
            }
            pointInfo.setMetadataX(Double.valueOf(metadataX.getText()));
            pointInfo.setMetadataY(Double.valueOf(metadataY.getText()));

            if (!PrPlugUtil.isDouble(materialNameX.getText()) || !PrPlugUtil.isDouble(materialNameY.getText())) {
                AlertUtil.showErrorAlert("素材名称点不能为空");
                return;
            }
            pointInfo.setMaterialNameX(Double.valueOf(materialNameX.getText()));
            pointInfo.setMaterialNameY(Double.valueOf(materialNameY.getText()));

            if (!PrPlugUtil.isDouble(audioX.getText()) || !PrPlugUtil.isDouble(audioY.getText())) {
                AlertUtil.showErrorAlert("音频点不能为空");
                return;
            }
            pointInfo.setAudioX(Double.valueOf(audioX.getText()));
            pointInfo.setAudioY(Double.valueOf(audioY.getText()));

            if (!PrPlugUtil.isDouble(materialClickX.getText()) || !PrPlugUtil.isDouble(materialClickY.getText())) {
                AlertUtil.showErrorAlert("素材点击区不能为空");
                return;
            }
            pointInfo.setMaterialClickX(Double.valueOf(materialClickX.getText()));
            pointInfo.setMaterialClickY(Double.valueOf(materialClickY.getText()));

            if (!PrPlugUtil.isDouble(effectX.getText()) || !PrPlugUtil.isDouble(effectY.getText())) {
                AlertUtil.showErrorAlert("效果区不能为空");
                return;
            }
            pointInfo.setEffectX(Double.valueOf(effectX.getText()));
            pointInfo.setEffectY(Double.valueOf(effectY.getText()));

            if (!PrPlugUtil.isDouble(effectInputX.getText()) || !PrPlugUtil.isDouble(effectInputY.getText())) {
                AlertUtil.showErrorAlert("效果输入框不能为空");
                return;
            }
            pointInfo.setEffectInputX(Double.valueOf(effectInputX.getText()));
            pointInfo.setEffectInputY(Double.valueOf(effectInputY.getText()));

            if (!PrPlugUtil.isDouble(effectClickX.getText()) || !PrPlugUtil.isDouble(effectClickY.getText())) {
                AlertUtil.showErrorAlert("效果选中区不能为空");
                return;
            }
            pointInfo.setEffectClickX(Double.valueOf(effectClickX.getText()));
            pointInfo.setEffectClickY(Double.valueOf(effectClickY.getText()));

            if (!PrPlugUtil.isDouble(videoStartX.getText()) || !PrPlugUtil.isDouble(videoStartY.getText())) {
                AlertUtil.showErrorAlert("视频轨道起始点不能为空");
                return;
            }
            pointInfo.setVedioStartX(Double.valueOf(videoStartX.getText()));
            pointInfo.setVedioStartY(Double.valueOf(videoStartY.getText()));

            if (!PrPlugUtil.isDouble(videoEndX.getText()) || !PrPlugUtil.isDouble(videoEndY.getText())) {
                AlertUtil.showErrorAlert("视频轨道结束点不能为空");
                return;
            }
            pointInfo.setVedioEndX(Double.valueOf(videoEndX.getText()));
            pointInfo.setVedioEndY(Double.valueOf(videoEndY.getText()));

            if (!PrPlugUtil.isDouble(multiple.getText()) && Double.valueOf(multiple.getText()) == 1) {
                AlertUtil.showErrorAlert("倍数不能为空,且不能为1");
                return;
            }
            pointInfo.setMultiple(Double.valueOf(multiple.getText()));

            pointInfo.setIgnore(ignore.getText());

            List<String> effectCheckList = new ArrayList<>();

            for (int i = 0; i < effectCheckBox.getChildren().size(); i++) {
                CheckBox temp = (CheckBox)effectCheckBox.getChildren().get(i);
                if(temp.isSelected()){
                    effectCheckList.add(temp.getText());
                }
            }
            pointInfo.setEffectCheckBox(effectCheckList);

            pointInfo.setFrequency(Double.valueOf(frequency.getValue()).intValue());

            Writer out = new FileWriter(file);
            out.write(JSONObject.toJSONString(pointInfo));
            out.close();


            //移动到任务栏并点击
            robot.mouseMove(pointInfo.getPrtaskbarX().intValue(), pointInfo.getPrtaskbarY().intValue());
            robot.mousePress(KeyEvent.BUTTON1_MASK);
            robot.mouseRelease(KeyEvent.BUTTON1_MASK);
            robot.delay(pointInfo.getFrequency() + 150);


            //需要截图的位置只需要第一次计算即可
            int videoTrackX = 0;
            int videoTrackY = 0;
            int videoTrackHeight = 0;
            int videoTrackWidth = 0;
            String videoTrackImg = "." + File.separator + APPDATA_FOLDER + File.separator + VIDEO_TRACK;

            videoTrackX = pointInfo.getVedioStartX().intValue();
            videoTrackWidth = (pointInfo.getVedioEndX().intValue() - pointInfo.getVedioStartX().intValue());

            if(pointInfo.getVedioStartY() > pointInfo.getVedioEndY()){
                videoTrackY = pointInfo.getVedioEndY().intValue();
                videoTrackHeight = (pointInfo.getVedioStartY().intValue() - pointInfo.getVedioEndY().intValue());
            }else{
                videoTrackY = pointInfo.getVedioStartY().intValue();
                videoTrackHeight = (pointInfo.getVedioEndY().intValue() - pointInfo.getVedioStartY().intValue());
            }
            if(videoTrackHeight <= 0){
                videoTrackHeight = 1;
            }
            if(videoTrackWidth <= 0){
                videoTrackWidth = 1;
            }

            stopFlag = false;
            //因为区分文字以及视频专场使用问题，使用前推，判断上一节点的素材类型
            Boolean beforeSkipFlag = null;
            while (true){

                if(stopFlag){
                    break;
                }

                //点击音频点 -- 单机
                robot.mouseMove(pointInfo.getAudioX().intValue(), pointInfo.getAudioY().intValue());
                robot.mousePress(KeyEvent.BUTTON1_MASK);
                robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                robot.delay(pointInfo.getFrequency());
                //双击素材区 //选中素材
                robot.mouseMove(pointInfo.getMaterialClickX().intValue(), pointInfo.getMaterialClickY().intValue());
                robot.mousePress(KeyEvent.BUTTON1_MASK);
                robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                robot.mousePress(KeyEvent.BUTTON1_MASK);
                robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                robot.delay(pointInfo.getFrequency());

                //点击元数据 -- 获取素材名称
                robot.mouseMove(pointInfo.getMetadataX().intValue(), pointInfo.getMetadataY().intValue());
                robot.mousePress(KeyEvent.BUTTON1_MASK);
                robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                robot.delay(pointInfo.getFrequency());

                String materialName = getMaterialName(pointInfo);

                boolean skipFlag = false;
                //如果为空 则判定为文字不做处理
                if (PrPlugUtil.isEmpty(materialName)) {
                    skipFlag = true;
                } else {
                    materialName = materialName.trim();
                    if (!PrPlugUtil.isEmpty(pointInfo.getIgnore())) {
                        //判断后缀名 是否需要忽略
                        String[] ignoreArr = pointInfo.getIgnore().split(",");
                        for (int i = 0; i < ignoreArr.length; i++) {
                            String ignoreTemp = ignoreArr[i];
                            if (ignoreTemp.startsWith(".")) {
                                ignoreTemp = ignoreTemp.substring(1);
                            }
                            if (!PrPlugUtil.isEmpty(ignoreTemp)) {
                                skipFlag = materialName.endsWith(ignoreTemp);
                                if (skipFlag) {
                                    break;
                                }
                            }
                        }
                    }
                }
                //点回效果空间
                robot.mouseMove(pointInfo.getControlX().intValue(), pointInfo.getControlY().intValue());
                robot.mousePress(KeyEvent.BUTTON1_MASK);
                robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                robot.delay(pointInfo.getFrequency());

                //此处追加 转场
                //跳到开始节点
                robot.mouseMove(pointInfo.getZoomStartX().intValue(), pointInfo.getZoomStartY().intValue());
                robot.mousePress(KeyEvent.BUTTON1_MASK);
                robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                robot.delay(pointInfo.getFrequency());
                if(beforeSkipFlag != null){

                    //找到是否需要加入转场
                    List<String> box = pointInfo.getEffectCheckBox();
                    if(box != null && box.size() > 0){
                        //随机确认加入哪个转场

                        int index = (int)(Math.random() * box.size());

                        //判断当前蓝线位置
                        File videoFile = ImageUtil.getScreenshot(videoTrackImg, "png", videoTrackX, videoTrackY, videoTrackWidth, videoTrackHeight);

                        Integer blueIndex = ImageUtil.getBlueIndexInImage(videoFile);

                        if(blueIndex != null){

                            int videoX = videoTrackX + blueIndex;
                            int videoY = videoTrackY;

                            //单机效果
                            robot.mouseMove(pointInfo.getEffectX().intValue(), pointInfo.getEffectY().intValue());
                            robot.mousePress(KeyEvent.BUTTON1_MASK);
                            robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                            robot.delay(pointInfo.getFrequency());

                            //写入随机的值
                            String transitionValue = box.get(index);
                            if(skipFlag || beforeSkipFlag){
                                transitionValue = "黑场过渡";
                            }

                            setValue(pointInfo.getEffectInputX().intValue(),pointInfo.getEffectInputY().intValue(),transitionValue,pointInfo.getFrequency());

                            //按住效果选中区
                            robot.mouseMove(pointInfo.getEffectClickX().intValue(), pointInfo.getEffectClickY().intValue());
                            robot.mousePress(KeyEvent.BUTTON1_MASK);

                            //移动到视频边界出放手
                            robot.mouseMove(videoX, videoY);
                            robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                            robot.delay(pointInfo.getFrequency());
                        }
                    }
                }


                if (skipFlag) {//跳过
                    robot.mouseMove(pointInfo.getZoomEndX().intValue(), pointInfo.getZoomEndY().intValue());
                    robot.mousePress(KeyEvent.BUTTON1_MASK);
                    robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                    robot.delay(pointInfo.getFrequency());
                } else {//不跳过
                    //首先判断起始点与结束的点数值是否一致
                    //如果不一致则代表已经执行完成，跳出循环 // 如果一致则需要设置缩放

                    String oldvalue = getZoomDistValue(pointInfo);
                    if (oldvalue != null) {
                        oldvalue = oldvalue.trim();
                    }

                    //到达结束点
                    robot.mouseMove(pointInfo.getZoomEndX().intValue(), pointInfo.getZoomEndY().intValue());
                    robot.mousePress(KeyEvent.BUTTON1_MASK);
                    robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                    robot.delay(pointInfo.getFrequency());
                    String newvalue = getZoomDistValue(pointInfo);
                    if (newvalue != null) {
                        newvalue = newvalue.trim();
                    }

                    if (oldvalue != null && newvalue != null && !oldvalue.equals(newvalue)) {
                        //跳出循环
                        break;
                    }
                    //移动到起始点
                    robot.mouseMove(pointInfo.getZoomStartX().intValue(), pointInfo.getZoomStartY().intValue());
                    robot.mousePress(KeyEvent.BUTTON1_MASK);
                    robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                    robot.delay(pointInfo.getFrequency());

                    //点下 缩放点以及移动点
                    robot.mouseMove(pointInfo.getPositionX().intValue(), pointInfo.getPositionY().intValue());
                    robot.mousePress(KeyEvent.BUTTON1_MASK);
                    robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                    robot.delay(pointInfo.getFrequency());

                    robot.mouseMove(pointInfo.getZoomX().intValue(), pointInfo.getZoomY().intValue());
                    robot.mousePress(KeyEvent.BUTTON1_MASK);
                    robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                    robot.delay(pointInfo.getFrequency());


                    // 移动到结束点
                    robot.mouseMove(pointInfo.getZoomEndX().intValue(), pointInfo.getZoomEndY().intValue());
                    robot.mousePress(KeyEvent.BUTTON1_MASK);
                    robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                    robot.delay(pointInfo.getFrequency());

                    //写入缩放的数值

                    BigDecimal decOldValue = new BigDecimal(oldvalue);
                    BigDecimal devNewValue = decOldValue.multiply(new BigDecimal(pointInfo.getMultiple()));
                    devNewValue = devNewValue.setScale(2, BigDecimal.ROUND_UP);

                    setZoomDistValue(pointInfo, devNewValue);

                    //再次点击素材区
                    robot.mouseMove(pointInfo.getMaterialClickX().intValue(), pointInfo.getMaterialClickY().intValue());
                    robot.mousePress(KeyEvent.BUTTON1_MASK);
                    robot.mouseRelease(KeyEvent.BUTTON1_MASK);
                    robot.delay(pointInfo.getFrequency());
                }

                //按下空格移动到下个素材
                robot.keyPress(KeyEvent.VK_SPACE);
                robot.keyRelease(KeyEvent.VK_SPACE);
                robot.delay(1700 + pointInfo.getFrequency());
                //暂停移动
                robot.keyPress(KeyEvent.VK_SPACE);
                robot.keyRelease(KeyEvent.VK_SPACE);

                beforeSkipFlag = skipFlag;
                //break;
            }

        }catch (Exception ex){

        }

    }

    private String getMaterialName(PointInfo pointInfo) {
        return getPrTextValue(pointInfo.getMaterialNameX().intValue(),pointInfo.getMaterialNameY().intValue(),pointInfo.getFrequency());
    }

    private String getZoomDistValue(PointInfo pointInfo){
        return getPrTextValue(pointInfo.getZoomDistX().intValue(),pointInfo.getZoomDistY().intValue(),pointInfo.getFrequency());
    }
    private String getPrTextValue(int x,int y,int frequency) {

        //清空剪切板
        PrPlugUtil.setClipboardString("");

        //双击缩放区获取缩放未变化的值
        robot.mouseMove(x,y);
        robot.mousePress(KeyEvent.BUTTON1_MASK);
        robot.mouseRelease(KeyEvent.BUTTON1_MASK);
        robot.mousePress(KeyEvent.BUTTON1_MASK);
        robot.mouseRelease(KeyEvent.BUTTON1_MASK);
        robot.delay(frequency);

        //ctrl + A ctrl + C 讲数值考入剪切板
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);

        robot.keyPress(KeyEvent.VK_C);
        robot.keyRelease(KeyEvent.VK_C);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.delay(frequency);

        //得到剪切板的内容
        return PrPlugUtil.getClipboardString();
    }

    private void setZoomDistValue(PointInfo pointInfo,BigDecimal value){

        setValue(pointInfo.getZoomDistX().intValue(),pointInfo.getZoomDistY().intValue(),value.toString(),pointInfo.getFrequency());

    }

    private void setValue(int x,int y,String value,int frequency){

        PrPlugUtil.setClipboardString(value);

        robot.mouseMove(x,y);
        robot.mousePress(KeyEvent.BUTTON1_MASK);
        robot.mouseRelease(KeyEvent.BUTTON1_MASK);
        robot.mousePress(KeyEvent.BUTTON1_MASK);
        robot.mouseRelease(KeyEvent.BUTTON1_MASK);
        robot.delay(frequency);

        // ctrl + V
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);
        robot.keyPress(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.delay(frequency);

    }

    private static final Double default_multiple = 1.5;
    private static final String default_ignore = ".gif,.mp4,.mov,.mkv";

    private void initPointInfo(){

        //渲染checkBox
        String effectDataPath = "." + File.separator + APPDATA_FOLDER + File.separator + APPDATA_EFFECT;

        File effectData = new File(effectDataPath);
        if(!effectData.exists()){

            try {

                File folder = new File("." + File.separator + APPDATA_FOLDER);
                if(!folder.exists()){
                    folder.mkdir();
                }

                Writer out = new FileWriter(effectData);
                out.write(PrPlugUtil.effectData);
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        List<String> effectCheckList = null;
        try {
            String temp = PrPlugUtil.getValueFromFile(effectData);
            effectCheckList = JSONArray.parseArray(temp, String.class);

        }catch (Exception ex){

        }

        String pointDataPath = "." + File.separator + APPDATA_FOLDER + File.separator + APPDATA_POINT;

        File file = new File(pointDataPath);
        if(!file.exists()){
            multiple.setText(default_multiple.toString());
            ignore.setText(default_ignore);

            if(effectCheckList != null){

                for (int i = 0; i < effectCheckList.size(); i++) {

                    String effectCheck = effectCheckList.get(i);

                    CheckBox checkBox = new CheckBox();
                    checkBox.setText(effectCheck);
                    checkBox.setSelected(true);

                    effectCheckBox.getChildren().add(checkBox);
                }
            }

            return;
        }
        try {

            String temp = PrPlugUtil.getValueFromFile(file);

            PointInfo pointInfo = JSONObject.parseObject(temp,PointInfo.class);

            if(PrPlugUtil.isEmpty(pointInfo.getMultiple())){
                multiple.setText(default_multiple.toString());
            }else{
                multiple.setText(pointInfo.getMultiple().toString());
            }

            List<String> effectCheckBoxList = pointInfo.getEffectCheckBox();
            if(effectCheckBoxList == null){
                effectCheckBoxList = new ArrayList<>();
            }
            for (int i = 0; i < effectCheckList.size(); i++) {

                String effectCheck = effectCheckList.get(i);
                boolean effectCheckTemp = false;
                for (int j = 0; j < effectCheckBoxList.size(); j++) {
                    if(effectCheck.equals(effectCheckBoxList.get(j))){
                        effectCheckTemp = true;
                    }
                }

                CheckBox checkBox = new CheckBox();
                checkBox.setText(effectCheck);
                checkBox.setSelected(effectCheckTemp);

                effectCheckBox.getChildren().add(checkBox);
            }

            ignore.setText(PrPlugUtil.safeValue(pointInfo.getIgnore()));

            ImgViewPoint imgViewPoint;

            imgViewPoint = setPoint(pointInfo.getPrtaskbarX(),pointInfo.getPrtaskbarY(), prtaskbar, prtaskbarLabel, prtaskbarX, prtaskbarY, "PR任务栏");
            prtaskbar = imgViewPoint.getImageView();
            prtaskbarLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getControlX(),pointInfo.getControlY(),control,controlLabel,controlX,controlY,"效果控件");
            control = imgViewPoint.getImageView();
            controlLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getPositionX(),pointInfo.getPositionY(),position,positionLabel,positionX,positionY,"位置移动点");
            position = imgViewPoint.getImageView();
            positionLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getZoomX(),pointInfo.getZoomY(),zoom,zoomLabel,zoomX,zoomY,"缩放点");
            zoom = imgViewPoint.getImageView();
            zoomLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getZoomDistX(),pointInfo.getZoomDistY(),zoomDist,zoomDistLabel,zoomDistX,zoomDistY,"缩放数值点");
            zoom = imgViewPoint.getImageView();
            zoomLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getZoomStartX(),pointInfo.getZoomStartY(),zoomStart,zoomStartLabel,zoomStartX,zoomStartY,"缩放起始点");
            zoomStart = imgViewPoint.getImageView();
            zoomStartLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getZoomEndX(),pointInfo.getZoomEndY(),zoomEnd,zoomEndLabel,zoomEndX,zoomEndY,"缩放结束点");
            zoomEnd = imgViewPoint.getImageView();
            zoomEndLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getMetadataX(),pointInfo.getMetadataY(),metadata,metadataLabel,metadataX,metadataY,"元数据");
            metadata = imgViewPoint.getImageView();
            metadataLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getMaterialNameX(),pointInfo.getMaterialNameY(),materialName,materialNameLabel,materialNameX,materialNameY,"素材名称点");
            materialName = imgViewPoint.getImageView();
            materialNameLabel = imgViewPoint.getLabel();

            /*imgViewPoint = setPointArea(pointInfo.getMaterialZoomX1(),pointInfo.getMaterialZoomY1(),materialZoom,materialZoomLabel,materialZoomX1,materialZoomY1
                    ,materialZoomX1,materialZoomY1
                    ,materialZoomX2,materialZoomY2
                    ,materialZoomX3,materialZoomY3
                    ,materialZoomX4,materialZoomY4
                    ,"素材缩放区");
            materialZoom = imgViewPoint.getImageView();
            materialZoomLabel = imgViewPoint.getLabel();*/

            imgViewPoint = setPoint(pointInfo.getAudioX(),pointInfo.getAudioY(),audio,audioLabel,audioX,audioY,"音频点");
            audio = imgViewPoint.getImageView();
            audioLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getMaterialClickX(),pointInfo.getMaterialClickY(),materialClick,materialClickLabel,materialClickX,materialClickY,"素材点击区");
            materialClick = imgViewPoint.getImageView();
            materialClickLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getEffectX(),pointInfo.getEffectY(),effect,effectLabel,effectX,effectY,"效果区");
            effect = imgViewPoint.getImageView();
            effectLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getEffectInputX(),pointInfo.getEffectInputY(),effectInput,effectInputLabel,effectInputX,effectInputY,"效果输入框");
            effectInput = imgViewPoint.getImageView();
            effectInputLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getEffectClickX(),pointInfo.getEffectClickY(),effectClick,effectClickLabel,effectClickX,effectClickY,"效果选中区");
            effectClick = imgViewPoint.getImageView();
            effectClickLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getVedioStartX(),pointInfo.getVedioStartY(),videoStart,videoStartLabel,videoStartX,videoStartY,"视频轨道起始点");
            videoStart = imgViewPoint.getImageView();
            videoStartLabel = imgViewPoint.getLabel();

            imgViewPoint = setPoint(pointInfo.getVedioEndX(),pointInfo.getVedioEndY(),videoEnd,videoEndLabel,videoEndX,videoEndY,"视频轨道结束点");
            videoEnd = imgViewPoint.getImageView();
            videoEndLabel = imgViewPoint.getLabel();

            Integer frequencyValue = pointInfo.getFrequency();
            if(frequencyValue == null || frequencyValue < 100){
                frequencyValue = 100;
            }
            if(frequencyValue > 2000){
                frequencyValue = 2000;
            }

            frequency.setValue(frequencyValue);
            frequencyLabel.setText(frequencyValue.toString());
        } catch (Exception e) {
            multiple.setText(default_multiple.toString());
            ignore.setText(default_ignore);
        }
    }

    @FXML
    public void openSNMessage(){
        SNMessageController controller = (SNMessageController) loadFXMLPage("帮助", FXMLPage.SNMessage, false);
        controller.setPrPlugController(this);

        controller.showDialogStage();
    }

    @Override
    public void closeHandler() {
        if(hotkeyListener != null){
            JIntellitype.getInstance().removeHotKeyListener(hotkeyListener);

            JIntellitype.getInstance().unregisterHotKey(1);
        }
        System.exit(0);
    }
}
